Bulk import cmd for "mail contacts" and csv headers?
Hi guys,
Im looking to add about 100 "mail contacts" to my Exchange 2007 server.
My CSV file is as follows;
First Name
Last Name
E-mail Address
Company
Organizational Unit
Alias
Recipient Type Details
Andy
Smith
andysmith@contoso.com
Contoso
contoso.com/marketing
Andy Smith
Mail Contact
Being that I have the CSV heading like that, what do I need to add/change to make importing work?
What is the cmd that I need to type to import this CSV into Exchange?
Thanks in advance for your help Guys.
April 13th, 2011 3:00pm
The actual CSV shows like this sorry;
First Name,Last Name,E-mail Address,Company,Organizational Unit,Alias,Recipient Type Details
Andy,Smith,andysmith@contoso.com,Contoso,contoso.com/marketing,Andy Smith,Mail Contact
Free Windows Admin Tool Kit Click here and download it now
April 13th, 2011 3:04pm
Haven't tested it, but something like this?
Import-CSV C:\Contacts.csv | ForEach-Object {
New-MailContact -Name ($_."First Name"+” “+$_."Last Name") -DisplayName ($_."First Name"+” “+$_."Last Name") -FirstName $_."First Name" -LastName $_."Last Name" -Alias $_."Alias" -OrganizationalUnit $_."Organizational Unit"
-ExternalEmailAddress $_."Email Address"
Set-MailContact $_."DisplayName" -Company $_."Company"
}
April 13th, 2011 6:38pm
I think so. But you have to use Set-Contact to change the Company value for the contacts since there is no Company parameter for
Set-MailContact:
Set-MailContact
http://technet.microsoft.com/en-us/library/aa995950(EXCHG.80).aspx
Frank Wang
TechNet Subscriber Support
in forum
If you have any feedback on our support, please contact
tngfb@microsoft.com
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
April 14th, 2011 5:26am
Chris, I tried the command, perhaps Im entering this wrong;
[PS] C:\>Import-CSV C:\Contacts.csv | ForEach-Object {
>> New-MailContact -Name ($_."First Name"+" "+$_."Last Name") -DisplayName ($_."First Name"+" "+$_."Last Name") -FirstName $_."First Name" -LastName $_."Last Name" -Alias $_."Alias" -OrganizationalUnit $_."Organizational Unit" -ExternalEmailAddress
$_."Email Address"
>>
>>
Nothings imported... Its probably something in the way how Im entering this command?
April 14th, 2011 8:57am
Did you include these 2 lines in what you pasted?
Set-MailContact $_."DisplayName" -Company $_."Company"
}
Free Windows Admin Tool Kit Click here and download it now
April 14th, 2011 11:15am
[PS] C:\>Import-CSV C:\Contacts.csv | ForEach-Object {
>> New-MailContact -Name ($_."First Name"+" "+$_."Last Name") -DisplayName ($_."First Name"+" "+$_."Last Name") -FirstName $_."First Name" -LastName $_."Last Name" -Alias $_."Alias" -OrganizationalUnit $_."Organizational Unit" -ExternalEmailAddress
$_."Email Address"
>>
>>
Yes, you omit the } in the cmdlet.
This is worked for me:
C:\>Import-CSV C:\Contacts.csv | ForEach-Object {
>> New-MailContact -Name ($_."First Name"+" "+$_."Last Name") -DisplayName ($_."First Name"+" "+$_."Last Name") -FirstName $_."First Name" -LastName $_."Last Name" -Alias $_."Alias" -OrganizationalUnit $_."Organizational Unit" -ExternalEmailAddress
$_."Email Address"
>>Set-Contact ($_."First Name"+" "+$_."Last Name") -company $_."company"
>>}
>>
Frank Wang
TechNet Subscriber Support
in forum
If you have any feedback on our support, please contact
tngfb@microsoft.com
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
April 14th, 2011 11:32pm
Hmmmm... Im lost. :(
Doesnt seem to work for me...
Am I missing a step somewhere?
1. I am doing this thru the Exchange Server using the Exchange Management Shell.
2. I have the contacts.csv file located on the C: of the Exchange server.
3. Im logged in as Global "Administrator"
4. Copy/Pasting:
[PS] C:\Documents and Settings\Administrator\Desktop>Import-CSV C:\Contacts.csv | ForEach-Object {
>> New-MailContact -Name ($_."First Name"+" "+$_."Last Name") -DisplayName ($_."First Name"+" "+$_."Last Name") -FirstName $_."First Name" -LastName $_."Last N
ame" -Alias $_."Alias" -OrganizationalUnit $_."Organizational Unit" -ExternalEmailAddress $_."E-mail Address"
>> Set-Contact ($_."First Name"+" "+$_."Last Name") -company $_."company"
>> }
>>
Please note I changed your -ExternalEmailAddress $_."Email Address" to -ExternalEmailAddress $_."E-mail Address" to match the headers in the csv file.
5. Ive also made sure AD actually has the correct OUs listed, in case they needed to be there before this was run.
What am I missing, thank for all the help guys...
Free Windows Admin Tool Kit Click here and download it now
April 15th, 2011 9:12am
Hi ChocheMSExportNot,
After you enter the cmdlet, nothing happened?
Please try to run the two cmdlets separately to see whether it works.
Import-CSV C:\Contacts.csv | ForEach-Object {New-MailContact -Name ($_."First Name"+" "+$_."Last Name") -DisplayName ($_."First Name"+" "+$_."Last Name") -FirstName $_."First Name" -LastName $_."Last Name" -Alias $_."Alias" -OrganizationalUnit
$_."Organizational Unit" -ExternalEmailAddress $_."E-mail Address" }
Frank Wang
TechNet Subscriber Support
in forum
If you have any feedback on our support, please contact
tngfb@microsoft.com
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
April 17th, 2011 10:50pm
Hi ChocheMSExportNot,
Any updates?Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
April 19th, 2011 9:20pm
Sorry guys, been out sick...
I entered the last cmdlet you sent me: results:
New-MailContact : Cannot bind parameter 'Alias' to the target. Exception settin
g "Alias": ""Wendy Meuse" is not valid for Alias. Valid values are: Strings for
med with characters from a to z (uppercase or lowercase), digits from 0 to 9, !
, #, $, %, &, ', *, +, -, /, =, ?, ^, _, `, {, |, } or ~. One or more periods m
ay be embedded in an alias, but each one of them should be preceded and followe
d by at least one of the other characters. Unicode characters from U+00A1 to U+
00FF are also valid in an alias, but they will be mapped to a best-fit US-ASCII
string in the email address which is generated from such an alias."
At line:1 char:214
+ Import-CSV C:\Contacts.csv | ForEach-Object {New-MailContact -Name ($_."First
Name"+" "+$_."Last Name") -DisplayName ($_."First Name"+" "+$_."Last Name") -
FirstName $_."First Name" -LastName $_."Last Name" -Alias <<<< $_."Alias" -Org
anizationalUnit $_."Organizational Unit" -ExternalEmailAddress $_."E-mail Addre
ss" }
+ CategoryInfo : WriteError: (:) [New-MailContact], ParameterBind
ingException
+ FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.Exchange.Manage
ment.RecipientTasks.NewMailContact
April 20th, 2011 10:42am
Hi ChocheMSExportNot,
The blank space is not a valid character to alias(Wendy Meuse)".
You can enter Wendy.Meuse or other valid characters.
Frank Wang
TechNet Subscriber Support
in forum
If you have any feedback on our support, please contact
tngfb@microsoft.com
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2011 11:38pm
New-MailContact : Cannot bind argument to parameter 'ExternalEmailAddress' because it is null.
At line:1 char:292
+ Import-CSV C:\Contacts.csv | ForEach-Object {New-MailContact -Name ($_."First Name"+" "+$_."Last Name") -DisplayName ($_."First Name"+" "+$_."Last Name") -
FirstName $_."First Name" -LastName $_."Last Name" -Alias $_."Alias" -OrganizationalUnit $_."Organizational Unit" -ExternalEmailAddress <<<< $_."E-mail Address" }
+ CategoryInfo : InvalidData: (:) [New-MailContact], ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Exchange.Management.RecipientTasks.NewMailContact
April 22nd, 2011 7:57am
Hi ChocheMSExportNot,
The cmdlet is OK in my test lab.
Could you please just run the New-MailContact to create a contact instead of bulk creation?
Frank Wang
TechNet Subscriber Support
in forum
If you have any feedback on our support, please contact
tngfb@microsoft.com
Please remember to click Mark as Answer on the post that helps you, and to click Unmark as Answer if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Free Windows Admin Tool Kit Click here and download it now
April 24th, 2011 10:48pm